package cn.wolfcode.trip.app.controller;


import cn.wolfcode.trip.base.domain.Wallet;
import cn.wolfcode.trip.base.service.IWalletService;
import cn.wolfcode.trip.base.util.JSONResult;
import com.sun.org.apache.regexp.internal.RE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.core.ReactiveTypeDescriptor;
import org.springframework.web.bind.annotation.*;

/**
 * 钱包资源
 */
@RestController
@RequestMapping("wallets")
public class WalletController {
    @Autowired
    private IWalletService walletService;

    /**
     * 通过用户id查询当前余额
     * @param userId
     * @return
     */
    @GetMapping("{userId}")
    public Wallet getWallet(@PathVariable("userId") Long userId){
        return walletService.get(userId);
    }

    /**
     * 充值服务
     * @param wallet
     * @return
     */
    @PostMapping("charge")
    public JSONResult charge(Wallet wallet){
        walletService.charge(wallet);
        return new JSONResult();
    }



}
